package com.ymatou.query.trading.api.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetVaildCouponListBean;
import com.ymatou.query.trading.api.service.GetVaildCouponListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.common.entitie.ProductInfoForCoupon;
import com.ymttest.common.enums.PlatformEnum;
import com.ymttest.utils.constant.ECode;

/**
 * 获取有效的优惠券列表 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetVaildCouponList {

	private static GetVaildCouponListBean getvaildcouponlistbean;
	private static GetVaildCouponListCall getvaildcouponlistcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取有效的优惠券列表");
	}

	@Before
	public void caseUp() {

		getvaildcouponlistbean = new GetVaildCouponListBean();
		getvaildcouponlistcall = new GetVaildCouponListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getvaildcouponlistcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	//@Test 废弃
	@Category(P1.class)
	@TestCase
	public void Tc_GetVaildCouponList_001() {
		Logger.start(true,"获取有效的优惠券列表成功");
		try {
			// 参数
			BigDecimal fcouponvalue = new BigDecimal(100);
			getvaildcouponlistbean.setAmount(fcouponvalue);
			getvaildcouponlistbean.setBuyerId(1113);
			ArrayList<ProductInfoForCoupon> list = new ArrayList<ProductInfoForCoupon>();
			ProductInfoForCoupon info = new ProductInfoForCoupon();
			info.setActivityId(1);
			info.setBrandId(1);
			info.setCategoryId(1);
			info.setCouponAvail4OrderDeduct(false);
			info.setIsActivityProduct(true);
			info.setLogisticsType(1);
			info.setProductId("1");
			list.add(info);
			getvaildcouponlistbean.setProductInfoForCouponList(list);
			getvaildcouponlistbean.setSellerId(288484);
			getvaildcouponlistbean.setUsePlatform(PlatformEnum.Ymt_PC);
			getvaildcouponlistbean.setUserLevel(3);
			// 发送请求
			getvaildcouponlistcall.setData(getvaildcouponlistbean);
			getvaildcouponlistcall.callService();
			Logger.comment("getvaildcouponlistcall send:" + getvaildcouponlistcall.getEntityString());
			Logger.comment("getvaildcouponlistcall response:" + getvaildcouponlistcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getvaildcouponlistcall.getCode(), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}